<?php
// +-------------------------------------------------------------------
// |
// +-------------------------------------------------------------------
// | Copyright (c) 2009-2016 All rights reserved.
// +-------------------------------------------------------------------
namespace Service\Api\V1;

class DiseaseList
{
    public $login = false; //是否需要登录才能访问该接口
    public $title = "眼病查询列表";
    public $group = '眼病';
    public $desc = "";

    public $input = [

    ];

    public $output = [
        'list' => [
            [
                'id' => 'label=分类id;',
                'name' => 'label=分类名称;',
                'article_list' => [
                    [
                        'id' => 'label=文章id;',
                        'title' => 'label=标题;',
                    ]
                ]
            ],
        ]
    ];

    public function run($param, $uid)
    {
        $type_list = (array)M('eyes_disease_type')->order('px asc')->select();
        foreach($type_list as &$item){
            $item['article_list'] = (array)M('eyes_disease')->field('id, title')->where([
                'status' => 1,
                'typeid' => $item['id'],
            ])->order('id asc')->select();
        }
        return ['list' => $type_list];
    }
}
